home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / x11 / strategy / xpat2-1.000 / xpat2-1 / xpat2-1.04 / src / r_Delight.c < prev    next >
C/C++ Source or Header  |  1994-04-22  |  3KB  |  94 lines

  1. /*****************************************************************************/
  2. /*                                         */
  3. /*                                         */
  4. /*    X patience version 2 -- module r_Delight.c                 */
  5. /*                                         */
  6. /*    Characteristics of the ``Idiot's Delight'' rules             */
  7. /*    written by Michael Bischoff (mbi@mo.math.nat.tu-bs.de)             */
  8. /*    31-Mar-1994                                 */
  9. /*    see COPYRIGHT.xpat2 for Copyright details                 */
  10. /*                                         */
  11. /*                                         */
  12. /*****************************************************************************/
  13. #include "xpatgame.h"
  14.  
  15. #define ACE_HIGHEST
  16.  
  17. static int ID_won(void) {
  18.     if (!EMPTY(IDECK))
  19.     return 0;
  20.     /* winning condition: */
  21.     /* there must be exactly 4 cards left on the slots! */
  22.     if (INDEX_OF_LAST_CARD(LAST_SLOT) - INDEX_OF_FIRST_CARD(FIRST_SLOT) != 3)
  23.     return 0;
  24.     return 1;
  25. }
  26.  
  27. static int ID_move_valid(Cardindex src, Pileindex dstpile) {
  28.     int i, thiscard;
  29.     Pileindex srcpile;
  30.  
  31.     srcpile = getpile(src);
  32.     if (game.piletype[srcpile] != Slot)
  33.     return 0;
  34.     if (game.piletype[dstpile] == Slot)
  35.     return EMPTY(dstpile);
  36.     if (game.piletype[dstpile] != Stack)
  37.     return 0;
  38.     /* slot to stack: must exist card of greater rank */
  39.     thiscard = game.cards[src];
  40.     for (i = FIRST_SLOT; i <= LAST_SLOT; ++i) {
  41.     int thatcard;
  42.     thatcard = game.cards[INDEX_OF_LAST_CARD(i)];
  43.     if (SUIT(thatcard) == SUIT(thiscard) &&
  44. #ifndef ACE_HIGHEST
  45.         RANK(thatcard) > RANK(thiscard)
  46. #else
  47.         /* wrap order */
  48.         (12+RANK(thatcard))%13 > (12+RANK(thiscard))%13
  49. #endif
  50.         )
  51.         return 1;
  52.     }
  53.     return 0;
  54. }
  55.  
  56. struct rules IdiotsDelight_rules = {
  57.     "Idiot's Delight",        /* shortname */
  58.     NULL,    /* longname */
  59.     "id",       /* abbrev */
  60.     2,        /* layout_hints */
  61.     0,        /* variant (DECK_SOURCE) */
  62.     0,        /* customizable */
  63.     0,        /* customized */
  64.     52,        /* numcards */
  65.     1,        /* numstacks */
  66.     4,        /* numslots */
  67.     0,        /* numtmps */
  68.     1,        /* numdecks */
  69.     13,        /* cards_per_color */
  70.     0,        /* numjokers */
  71.     {0, 0, 0, 0},/* param[0], param[1], param[2], param[3] */
  72.     0,        /* facedown */
  73.     1,        /* faceup */
  74.     0,        /* newgame_bits */
  75.     NULL,    /* new_game */
  76.     ID_won,    /* game_won */
  77.     NULL,    /* new_cards */
  78.     ES_ALL|US_NONE|MG_NONE|DC_ALWAYS|ST_ONE, /* move_bits */
  79.     NULL,    /* deal_cards */
  80.     NULL,    /* undeal_cards */
  81.     NULL,    /* stackable */
  82.     ID_move_valid,/* movevalid */
  83.     NULL,    /* valid */
  84.     NULL,    /* relaxed_valid */
  85.     NULL,    /* good_hint */
  86.     NULL,    /* automove */
  87.     NULL,    /* score */
  88.     0,        /* maxscore */
  89.     {0, 0, 0, 0}, /* paramstring blocks */
  90.     0,        /* used */
  91.     NULL,    /* initfunc */
  92.     NULL,    /* local keyboard bindings */
  93. };
  94.